<html>
<head><meta charset="utf-8"><title>preferred way to handle multiple ignores · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html">preferred way to handle multiple ignores</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="215968718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215968718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215968718">(Nov 07 2020 at 19:07)</a>:</h4>
<p>There's some code in the stdlib tests that looks roughly like:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[test]</span><span class="w"></span>
<span class="cp">#[cfg_attr(macos, ignore)]</span><span class="w"></span>
<span class="cp">#[cfg_attr(aarch64, ignore)]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">x</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>On aarch64 macos, that expands to two <code>#[ignore]</code> attributes, which then flags the second <code>ignore</code> as unused, which then fails the build. The easy fix is make the second one <code>all(aarch64, not(macos))</code>, but that feels ugly.</p>
<p>Any preferred approach here?</p>



<a name="215968934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215968934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215968934">(Nov 07 2020 at 19:13)</a>:</h4>
<p>cfg_attr I assume?</p>



<a name="215968945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215968945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215968945">(Nov 07 2020 at 19:13)</a>:</h4>
<p>Why do we need two ignores instead of (for example) <code>#[cfg_attr(any(macos, aarch64), ignore)]</code>?</p>



<a name="215968980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215968980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215968980">(Nov 07 2020 at 19:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/preferred.20way.20to.20handle.20multiple.20ignores/near/215968934">said</a>:</p>
<blockquote>
<p>cfg_attr I assume?</p>
</blockquote>
<p>fixed.</p>



<a name="215969020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969020">(Nov 07 2020 at 19:15)</a>:</h4>
<p>The <a href="https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/process/process_common/tests.rs#L17-L28">exact spot</a>:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// See #14232 for more information, but it appears that signal delivery to a</span>
<span class="c1">// newly spawned process may just be raced in the macOS, so to prevent this</span>
<span class="c1">// test from being flaky we ignore it on macOS.</span>
<span class="cp">#[test]</span><span class="w"></span>
<span class="cp">#[cfg_attr(target_os = </span><span class="s">"macos"</span><span class="cp">, ignore)]</span><span class="w"></span>
<span class="c1">// When run under our current QEMU emulation test suite this test fails,</span>
<span class="c1">// although the reason isn't very clear as to why. For now this test is</span>
<span class="c1">// ignored there.</span>
<span class="cp">#[cfg_attr(target_arch = </span><span class="s">"arm"</span><span class="cp">, ignore)]</span><span class="w"></span>
<span class="cp">#[cfg_attr(target_arch = </span><span class="s">"aarch64"</span><span class="cp">, ignore)]</span><span class="w"></span>
<span class="cp">#[cfg_attr(target_arch = </span><span class="s">"riscv64"</span><span class="cp">, ignore)]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">test_process_mask</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
</code></pre></div>
<p>I suppose that the comments could be combined into one block or interleaved between commas.</p>



<a name="215969087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969087">(Nov 07 2020 at 19:17)</a>:</h4>
<p>e.g.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[test]</span><span class="w"></span>
<span class="cp">#[cfg_attr(any(</span>
<span class="cp">    // See #14232 for more information, but it appears that signal delivery to a</span>
<span class="cp">    // newly spawned process may just be raced in the macOS, so to prevent this</span>
<span class="cp">    // test from being flaky we ignore it on macOS.</span>
<span class="cp">    target_os = </span><span class="s">"macos"</span><span class="cp">,</span>
<span class="cp">    // When run under our current QEMU emulation test suite this test fails,</span>
<span class="cp">    // although the reason isn't very clear as to why. For now this test is</span>
<span class="cp">    // ignored there.</span>
<span class="cp">    target_arch = </span><span class="s">"arm"</span><span class="cp">,</span>
<span class="cp">    target_arch = </span><span class="s">"aarch64"</span><span class="cp">,</span>
<span class="cp">    target_arch = </span><span class="s">"riscv64"</span><span class="cp">,</span>
<span class="cp">), ignore)]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">test_process_mask</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="215969134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969134">(Nov 07 2020 at 19:18)</a>:</h4>
<p>Hm</p>



<a name="215969143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969143">(Nov 07 2020 at 19:18)</a>:</h4>
<p>Does the interleaving of comments and attributes work? if so that seems like the best bet</p>



<a name="215969154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969154">(Nov 07 2020 at 19:19)</a>:</h4>
<p>It does seem like "overlapping equivalent attributes because of cfg" might be something we could not lint on</p>



<a name="215969160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969160">(Nov 07 2020 at 19:19)</a>:</h4>
<p>but not sure how easy that would be to detect, especially if you wanted to avoid <code>#[cfg_attr(unix, ignore)] #[cfg_attr(unix, ignore)]</code></p>



<a name="215969208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969208">(Nov 07 2020 at 19:20)</a>:</h4>
<p>That last example i pasted runs in the playground, so it appears syntactically valid</p>



<a name="215969220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969220">(Nov 07 2020 at 19:21)</a>:</h4>
<p>I can try it in the real code after this current test run finishes</p>



<a name="215969235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969235">(Nov 07 2020 at 19:21)</a>:</h4>
<p>yeah I would expect it to be, just wasn't sure</p>



<a name="215969279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969279">(Nov 07 2020 at 19:22)</a>:</h4>
<p>probably makes rustfmt give up</p>



<a name="215969291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969291">(Nov 07 2020 at 19:22)</a>:</h4>
<p>yeah, rustfmt is pretty mum for it; I indented by hand.</p>



<a name="215969306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/preferred%20way%20to%20handle%20multiple%20ignores/near/215969306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/preferred.20way.20to.20handle.20multiple.20ignores.html#215969306">(Nov 07 2020 at 19:23)</a>:</h4>
<p>(incorrectly, it appears)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>